import csv

student_list = [['hou', 'feng'], ['liu', 'wang'], ['zhang', 'zhao']]

# csv的写入
with open('./student.csv', 'w', newline='') as f:  # newline如果不设置成''，那么csv写入的时候会自动加一个空行
    # 创建csv文件写入对象
    csv_writer = csv.writer(f)
    # 写入多行
    csv_writer.writerows(student_list)

with open('./student.csv', 'a', newline='') as f:
    csv_writer = csv.writer(f)
    # 写入一行
    csv_writer.writerow(['h', 'q'])

# csv读取
with open('./student.csv') as f:
    # 读取csv文件，返回的是一个迭代器
    csv_reader = csv.reader(f)
    data = [row for row in csv_reader]

    print(data)
